package com.nuanqian.springbootdubboclient.controller;

import com.alibaba.dubbo.config.annotation.Reference;

import com.nuanqian.springbootdubboapi.service.TestService;
import com.nuanqian.springbootdubboentity.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 李蒙
 * @date 2020/6/17 16:51
 */
@RestController
@RequestMapping("/")
public class DubboTestController {
    @Reference(version = "1.0.0",group = "1")
    private TestService testService;
    @Reference(version = "1.0.0",group = "2")
    private TestService testService2;

    @GetMapping("hello/{type}")
    public String hello(@PathVariable("type") Integer type) {
        if (2== type){
            return testService2.sayHello("Hello springboot and dubbo!");
        }else {
            return testService.sayHello("Hello springboot and dubbo!");
        }
    }

    @GetMapping("user/{type}")
    public User user(@PathVariable("type") Integer type) {
        if (2== type){
            return testService2.findUser();
        }else {
            return testService.findUser();
        }

    }
}
